package com.doit.day01;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.mapreduce.TableMapReduceUtil;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;

public class Test {
    public static void main(String[] args) throws Exception {
        // 获取整合的初始化对象
        Configuration conf = HBaseConfiguration.create();
        // 连接ZK的位置
        conf.set("hbase.zookeeper.quorum", "linux01,linux02,linux03");
        // 获取job对象
        Job job = Job.getInstance(conf);
        // 穿件扫描对象用来扫描源hbase中的所有的数据
        Scan scan = new Scan();
        // 接收的扫描的数据的行数
        scan.setCaching(200);
        scan.setCacheBlocks(false);
        job.setJarByClass(Test.class);
        // TableMapReduceUtil.initTableMapJob("user", "f", MRMapper.class, Text.class,Text.class, job);
        // 初始化  源表
        TableMapReduceUtil.initTableMapperJob("user", scan, MapTask.class, Text.class, Text.class, job);
        // 插入数据的表要存在
        TableMapReduceUtil.initTableReducerJob("user2", ReduceTask.class, job);
        boolean b = job.waitForCompletion(true);
        if (b) {
            System.exit(1);
        }
    }

}
